use serde::{Deserialize, Serialize};
use QcMacros::Comp;

use crate::resources::material::Material;

#[derive(Debug, Comp, Clone, Serialize, Deserialize)]
pub struct MaterialRender {
    inner: ComponentInner,
    pub material_list: Vec<Material>,
}

impl MaterialRender {
    pub fn new() -> Self {
        Self {
            inner: ComponentInner::default(),
            material_list: vec![],
        }
    }

    pub fn with_material(mut self, material: Material) -> Self {
        self.material_list.push(material);
        self
    }

    pub fn addMaterial(&mut self, material: Material) {
        self.material_list.push(material);
    }

    pub fn getMaterialList(&self) -> &Vec<Material> {
        &self.material_list
    }

    pub fn setMaterialList(&mut self, materialList: Vec<Material>) {
        self.material_list = materialList;
    }

    pub fn get_material(&self, index: usize) -> &Material {
        &self.material_list[index]
    }

    pub fn get_material_mut(&mut self, index: usize) -> &mut Material {
        &mut self.material_list[index]
    }

    pub fn set_material(&mut self, index: usize, material: Material) {
        self.material_list[index] = material;
    }
}
